package ru.st.selenium.pages;

import java.util.List;

import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

public class SearchPages extends InternalPage {
	
		public SearchPages(PageManager pages) {
		super(pages);
	}
	
		@FindBy(id = "q")
		private WebElement searchField;
		
		@FindBy(xpath = "//div[contains(@class, 'movie_box')]")
		public List<WebElement> listResult;
				
		public SearchPages inputSearchField(String text) {
			searchField.sendKeys(text);
			    return this;
			  }
		
		public SearchPages clickSearchField() {
			searchField.sendKeys(Keys.RETURN);
			    return this;
			  }
		
		public boolean isNoMoviesMasseg() {
			return driver.getPageSource().contains("No movies where found");
			  }
		
		public boolean isNoMoviesMasseg(WebElement element, String name) {
			return element.getText().contains(name);
			  }
		
		public SearchPages waitResult(){
			try {
				Thread.sleep(1000);
			  } catch (InterruptedException e) {
				e.printStackTrace();
			  }
			return this;
		}
		
		public int sizeResult(){
			return listResult.size();
		}
}
